# Start from the code-server Debian base image
FROM codercom/code-server:3.12.0

USER coder

# Apply VS Code settings
COPY deploy-container/settings.json .local/share/code-server/User/settings.json


# Use bash shell
ENV SHELL=/bin/bash
ENV PASSWORD=111111
# Install unzip + rclone (support for remote filesystem)
RUN sudo apt-get update && sudo apt-get install unzip -y
RUN curl https://rclone.org/install.sh | sudo bash

# Copy rclone tasks to /tmp, to potentially be used
COPY deploy-container/rclone-tasks.json /tmp/rclone-tasks.json

# Fix permissions for code-server
RUN sudo chown -R coder:coder /home/coder/.local


# RUN yum install zsh

COPY ./oh-my-zsh.sh ./oh-my-zsh.sh
RUN sh oh-my-zsh.sh

# Add Nodejs
RUN sudo curl -fsSL https://deb.nodesource.com/setup_15.x | sudo bash -
RUN sudo apt-get install -y nodejs


# Add Rust Environment
RUN sudo apt-get install --assume-yes apt-utils
RUN sudo apt-get install curl -y
RUN sudo apt-get install cargo -y
#RUN export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
#COPY ./rustup.sh ./rustup.sh
#RUN sudo sh ./rustup.sh -y
#RUN sudo apt install build-essential -y
#ENV PATH="/root/.cargo/bin:${PATH}"
#RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
#RUN sudo source $HOME/.cargo/env
RUN sudo cargo --help



# You can add custom software and dependencies for your environment below
# -----------

# Install a VS Code extension:
# Note: we use a different marketplace than VS Code. See https://github.com/cdr/code-server/blob/main/docs/FAQ.md#differences-compared-to-vs-code
# RUN code-server --install-extension esbenp.prettier-vscode

# Install apt packages:
# RUN sudo apt-get install -y ubuntu-make

# Copy files: 
# COPY deploy-container/myTool /home/coder/myTool

# -----------

# Port
ENV PORT=8080

# Use our custom entrypoint script first
COPY deploy-container/entrypoint.sh /usr/bin/deploy-container-entrypoint.sh
ENTRYPOINT ["/usr/bin/deploy-container-entrypoint.sh"]
